<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>简单的 Post 请求</title>
</head>
<body>
<div id="app">

</div>

<script src="../../../../js/axios.js"></script>
<script type="module">
    import {createApp, onMounted} from "../../../../js/vue.esm-browser.js";

    let app = createApp(
        {
            setup() {


                function postRequest() {
                    axios.post(
                        "https://www.httpbin.org/post",
                        {
                            name: "abcque",
                            age: 18,
                            gender: "M",


                        }
                    )
                        .then(function (response) {
                            // console.log(typeof response);
                            console.log(response);
                            // string 类型
                            console.log(typeof response.data.data);
                            console.log(response.data.data);
                            console.log(typeof JSON.parse(response.data.data));
                            console.log(JSON.parse(response.data.data));
                            console.log(response.data.json);
                        })
                        .catch(function (error) {
                            console.log(error);
                        })
                        .finally(function () {

                        })
                }

                /*async function getRequest() {
                  try {
                    let response = await axios.get(
                            "https://www.httpbin.org/get",
                            {
                              params: {
                                name: "abcque",
                                age: 18,
                                gender: "M",
                              }

                            }
                    );

                    console.log(response);

                  } catch (e) {
                    console.log(e);
                  }

            }*/

                onMounted(
                    () => {
                        postRequest()
                    }
                )

                return {}
            }
        }
    )
    app.mount("#app")
</script>
</body>
</html>